module.exports = function ($scope, $state, $stateParams,$resource,$modal,FileUploader,toaster, $modalInstance, items, flag, type) {
    $scope.flag = flag;
    var company_id = items.company_id;
    console.log($scope.flag);
    $scope.type = type;
    console.log(type);
    var url = '';
    $scope.info = {
      'title' : ''
    }
    var url1 = '';
    var para = {};
    var paras = {};
    // 详情
    $scope.getInfo = function(){
      $resource('/api/as/ggc/reviewPlanning/findInfo', {}, {}).save({'project_code':items.project_code}, function(res){			              
          if(res.errcode === 0 || res.errcode === 10003){
              console.log('详情');
              console.log(res);
              $scope.a = res.data;
          }else{
              alert(res.errmsg);
          }
      });
    }
    $scope.getInfo();
    $scope.cancel = function(){
      $modalInstance.close();
    }
    $scope.ok = function(){
      if(type == '1' && flag == 'qxbh'){ // 区县初审驳回
      url = '/api/as/ggc/reviewDistrictTourism/updateByRecommendOff';
        para = {
          'recommend_district_message' : $scope.info.title,
          'project_code' : items.project_code,
        }
        paras = {
          'project_code':$scope.a.project_code, 
          'recommend_type' : $scope.a.recommend_type, 
          'check_city' : $scope.a.check_city, 
          'check_state' : '2', 
          'check_message' : $scope.info.title
        }
      } else if(type == '' && flag == 'zhsp'){ // 账号审批
        url = '/api/as/ggc/reviewCompany/updateStateDown';
        para = {
          'audit_no_message' : $scope.info.title,
          'company_id' : company_id
        }
      } else if(type == '1' && flag == 'qxtt'){ // 区县初审淘汰
        url = '/api/as/ggc/reviewDistrictTourism/updateByRecommendBack';
        para = {
          'recommend_district_message' : $scope.info.title,
          'project_code' : items.project_code
        }
        paras = {
          'project_code':$scope.a.project_code, 
          'recommend_type' : $scope.a.recommend_type, 
          'check_city' : $scope.a.check_city, 
          'check_state' : '3', 
          'check_message' : $scope.info.title
        }
      } else if(type == '0' && flag == 'sjbh'){ // 市级初审驳回
        url = '/api/as/ggc/reviewCityResponsible/updateReject';
        para = {
          'back_reason' : $scope.info.title,
          'project_code' : items.project_code
        }
        paras = {
          'project_code' : items.project_code,
          'recommend_type' : items.recommend_type,
          'check_message' : $scope.info.title,
          'check_state' : '2'
        }
      } else if(type == '0' && flag == 'sjtt'){ // 市级初审淘汰
        url = '/api/as/ggc/reviewCityResponsible/updateBack';
        para = {
          'eliminate_reason' : $scope.info.title,
          'project_code' : items.project_code
        }
        paras = {
          'project_code' : items.project_code,
          'recommend_type' : items.recommend_type,
          'check_message' : $scope.info.title,
          'check_state' : '3'
        }
      } else if(type == '1' && flag == 'sjfhbh'){ // 市级复核驳回
        url = '/api/as/ggc/reviewPlanning/updateBack';
        para = {
          'plan_back_reason' : $scope.info.title,
          'project_code' : items.project_code
        }
        paras = {
          'project_code' : items.project_code,
          'recommend_type' : '15',
          'check_message' : $scope.info.title,
          'check_state' : '2'
        }
      } else if(type == '1' && flag == 'sjfhtt'){ // 市级复核淘汰
        url = '/api/as/ggc/reviewPlanning/updateRec';
        para = {
          'plan_back_reason' : $scope.info.title,
          'project_code' : items.project_code
        }
        paras = {
          'project_code' : items.project_code,
          'recommend_type' : '15',
          'check_message' : $scope.info.title,
          'check_state' : '3'
        }
      } else if(type == '0' && flag == 'ghcfhbh'){ // 区县复核驳回(规划处)
        url = '/api/as/ggc/reviewPlanning/updateBack';
        para = {
          'plan_back_reason' : $scope.info.title,
          'project_code' : items.project_code
        }
        paras = {
          'project_code' : items.project_code,
          'recommend_type' : '15',
          'check_message' : $scope.info.title,
          'check_state' : '2'
        }
      } else if(type == '0' && flag == 'ghcfhtt'){ // 区县复核淘汰(规划处)
        url = '/api/as/ggc/reviewPlanning/updateRec';
        para = {
          'plan_back_reason' : $scope.info.title,
          'project_code' : items.project_code
        }
        paras = {
          'project_code' : items.project_code,
          'recommend_type' : '15',
          'check_message' : $scope.info.title,
          'check_state' : '3'
        }
      } else if(type == '3' && flag == 'zrcsfhbh'){ // 区县复核驳回(责任处室)
        url = '/api/as/ggc/reviewCityResponsible/updateReject';
        para = {
          'plan_back_reason' : $scope.info.title,
          'project_code' : items.project_code
        }
        paras = {
          'project_code' : items.project_code,
          'recommend_type' : items.recommend_type,
          'check_message' : $scope.info.title,
          'check_state' : '2'
        }
      } else if(type == '3' && flag == 'zrcsfhtt'){ // 区县复核淘汰(责任处室)
        url = '/api/as/ggc/reviewCityResponsible/updateBack';
        para = {
          'eliminate_reason' : $scope.info.title,
          'project_code' : items.project_code
        }
        paras = {
          'project_code' : items.project_code,
          'recommend_type' : items.recommend_type,
          'check_message' : $scope.info.title,
          'check_state' : '3'
        }
      }
      console.log(para);
      $resource(url, {}, {}).save(para, function(res){
          if(res.errcode != 0){   
              toaster.error({title:"",body:res.errmsg});
              return;
          }
          toaster.success({title:"",body:'操作成功'});
            $modalInstance.close();
      });
      $resource('/api/as/ggc/reviewPlanning/insertReviewCompanyProjectLog', {}, {}).save(paras, function(res){			              
          if(res.errcode === 0 || res.errcode === 10003){
              console.log(res);
          }else{
              alert(res.errmsg);
          }
      });
    }
}  